package com.test;
import java.io.IOException;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class CommodityReduce extends Reducer<Text, Commodity, Text, Text>{

    protected void reduce(Text k3, Iterable<Commodity> v3,Context context)throws IOException, InterruptedException{
        int total1 = 0;
        float total2 = 0;
        for(Commodity e:v3){
            total1 = total1 + e.getQuantity_sold();
            total2 = total2 + e.getAmount_sold();
        }
        String total = "销售笔数:" + Integer.toString(total1) + "," + "销售总额:" + Float.toString(total2);
        context.write(k3, new Text(total));
    }
}
